﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using WimaxSimulator.Wimax;
using System.Runtime.Serialization;

namespace WimaxSimulator.Gui
{
    [Serializable]
    public abstract class StationUI
    {
        public static bool CoverageEnable = true;
        [NonSerialized]
        private Brush brush;
        public Brush Brush { get { return brush; } set { brush = value; } }
        [NonSerialized]
        private Pen pen;
        public Pen Pen { get { return pen; } set { pen = value; } }
        public int Radius { get; set; }
        public StationUI(Station s)
        {
            this.Station = s;
            Initialize();
        }
        public Station Station { get; set; }
        public virtual void Paint(Graphics g)
        {
            g.FillEllipse(Brush, (float)Station.Location.X - Radius, (float)Station.Location.Y - Radius, 2 * Radius, 2 * Radius);
            g.DrawString(Station.Id + "", new Font(FontFamily.GenericMonospace, 9), Brushes.Black, Station.Location - new Size(Radius / 2, Radius / 2));
            g.DrawString(Station + "", new Font(FontFamily.GenericMonospace, 6), Brushes.Black, Station.Location + new Size(-5, Radius));
            if (CoverageEnable)
                g.DrawEllipse(Pen, Station.Location.X - Station.CoverageRadius, Station.Location.Y - Station.CoverageRadius, 2 * Station.CoverageRadius, 2 * Station.CoverageRadius);

        }

        public bool Intersects(Point p1)
        {
            return Station.Subtract(Station.Location, p1) < Radius;
        }
        public virtual void Initialize()
        {
            if (!SimulationEngine.stations.Contains(Station))
                SimulationEngine.stations.Add(Station);
            Radius = 10;
        }


    }
}
